﻿using System;
using System.Collections.Generic;
using System.Text;


using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;
using DevExpress.Xpo;
using DevExpress.Xpo.Metadata;
using OT.Module.ModelConst;
using OT.Common;
using OT.EntLib.Validate;

namespace OT.Module.Model
{
	
    [Persistent(GDB.Employee)]
	public class Employee : XPLiteObject
	{
        #region ~

        public Employee() : base ( new Session() )
        {

        }

        public Employee(Session s)
            : base(s)
        {
        }

        public Employee(Session s, XPClassInfo info)
            : base(s, info)
        {
        }

        #endregion
        
        
		#region ID  
		private string _ID = "";	
		
		[Key(false)]
		public string ID
		{
			get
			{
				return _ID;
			}
			set
			{
				SetPropertyValue("ID", ref _ID, value);
			}
		}
		#endregion
	
	
		#region Name  员工姓名
		private string _Name = "";	
		[DisplayName(GSyntax.Employee.Name), Size(50)]
		public string Name
		{
			get
			{
				return _Name;
			}
			set
			{
				SetPropertyValue("Name", ref _Name, value);
			}
		}
		#endregion
	
	
		#region BelongCity  
		private City _BelongCity;

        [Association("City-Employees")]
        public City BelongCity
        {
            get
            {
                return _BelongCity;
            }
            set
            {
                SetPropertyValue("BelongCity", ref _BelongCity, value);
            }
        }
		#endregion

        #region CityID  

        [NonPersistent]
        [DisplayName(GSyntax.City.Name)]
        public string CityID
        {
            get
            {
                string ret = "";
                if (BelongCity != null)
                    ret = BelongCity.ID;
                return ret;
            }
            set
            {
                BelongCity = Session.GetObjectByKey<City>(value);
            }
        }

        #endregion 

        #region ProvinceID  

        [NonPersistent]
        [DisplayName(GSyntax.Province.Name)]
        public string ProvinceID
        {
            get
            {
                string ret = "";
                if (BelongCity != null)
                    ret = BelongCity.BelongProvince.ID;
                return ret;
            }
            set
            {
            }
        }

        #endregion 

        #region BelongDepartment
        private Department _BelongDepartment;

        [Association("Department-Employees")]
        public Department BelongDepartment
        {
            get
            {
                return _BelongDepartment;
            }
            set
            {
                SetPropertyValue("BelongDepartment", ref _BelongDepartment, value);
            }
        }
		#endregion


        #region DepartmentID

        [NonPersistent]
        [DisplayName(GSyntax.Department.Name)]
        public string DepartmentID
        {
            get
            {
                string ret = "";
                if (BelongDepartment != null)
                    ret = BelongDepartment.ID;
                return ret;
            }
            set
            {
                BelongDepartment = Session.GetObjectByKey<Department>(value);
            }
        }

        #endregion 

        #region CompanyID

        [NonPersistent]
        [DisplayName(GSyntax.Company.Name)]
        public string CompanyID
        {
            get
            {
                string ret = "";
                if (BelongDepartment != null)
                    ret = BelongDepartment.BelongCompany.CompanyID;
                return ret;
            }
            set
            {
            }
        }

        #endregion 

    }
	
}
	